package com.chunayev.numerology.gui.util;

import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.Window;

/**
 * @author Sergey Chunayev
 */
public class ComponentDisplayManager {
    
    private static final int screenX;
    private static final int screenY;
    static {
        final Toolkit toolkit = Toolkit.getDefaultToolkit();
        final Dimension screenSize = toolkit.getScreenSize();
        screenX = screenSize.width;
        screenY = screenSize.height;
    }
    
    public static void centralize(final Window window) {
        final int height = window.getHeight();
        final int width = window.getWidth();
        final int x = (screenX - width) / 2;
        final int y = (screenY - height) / 2;
        
        window.setBounds(x, y, width, height);
    }
}
